/* 
Copyright (c) 2004,2005, 2006, 2007, 2008 University of Illinois 

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

3. The name of the author may not be used to endorse or promote products
   derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
AccessibilityExtension.ns(function() { with (AccessibilityExtension.LIB) {

	var AE = AccessibilityExtension.ns;  
//	var errMsgArray = new Array();
	var activeTreeboxes = Array();
	var HOME = 'http://bestpractices.cita.uiuc.edu/html';
	var WCAGHOME = 'http://www.openajax.org/member/wiki/Accessibility';
	
	var errMsgArray = [
	    {  name:'titles.warnings.missingOrEmptyTitle',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.fail', WCAG_2_0Link: WCAGHOME + '#Titling_Rules', BPLink: HOME + '/nav/title/' },
		{  name:'titles.warnings.missingOrEmptyH1',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.fail', WCAG_2_0Link: WCAGHOME + '#Titling_Rules', BPLink: HOME + '/nav/title/' },
	    {  name:'titles.msg.toolong',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.suggestion', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#Titling_Rules', BPLink: HOME + '/nav/title/' },
	    {  name:'titles.msg.oneword',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.suggestion', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#Titling_Rules', BPLink: HOME + '/nav/title/' },
		{  name:'titles.msg.titlemissingh1words',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.warn', WCAG_2_0Link: WCAGHOME + '#Titling_Rules', BPLink: HOME + '/nav/title/' },
		{  name:'titles.msg.titleh1wordorder',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.suggestion', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#Titling_Rules', BPLink: HOME + '/nav/title/' },
		{  name:'titles.msg.H1OnlyAlt',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.warn', WCAG_2_0Link: WCAGHOME + '#Titling_Rules', BPLink: HOME + '/nav/title/' },
		{  name:'titles.msg.toomanyh1',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.unenforced', WCAG_2_0: 'msg.warn', WCAG_2_0Link: WCAGHOME + '#Titling_Rules', BPLink: HOME + '/nav/title/' },
		{  name:'headers.warnings.toomanyfewh1',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#Headings', BPLink: HOME + '/nav/heading/' },
		{  name:'headers.warnings.impropernesting',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.fail', WCAG_2_0Link: WCAGHOME + '#Headings', BPLink: HOME + '/nav/heading/' },
		{  name:'headers.warnings.nonefound',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.fail', WCAG_2_0Link: WCAGHOME + '#Headings', BPLink: HOME + '/nav/heading/' },
		{  name:'headers.warnings.nonefoundARIA',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.fail', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#Headings', BPLink: HOME + '/nav/heading/' },
		//leave		{  name:'headers.msg.toomanymain','msg.unenforced','msg.suggestion','msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#Headings', BPLink: HOME + '/nav/heading/' },
		{  name:'headers.msg.emptyheader',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.fail', WCAG_2_0Link: WCAGHOME + '#Headings', BPLink: HOME + '/nav/heading/' },
		{  name:'headers.msg.siblingDupName',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.warn', WCAG_2_0Link: WCAGHOME + '#Headings', BPLink: HOME + '/nav/heading/' },
		{  name:'headers.msg.toolong',IITAA :'msg.suggestion',icita07 :'msg.suggestion',icita08 :'msg.unenforced', WCAG_2_0: 'msg.suggestion', WCAG_2_0Link: WCAGHOME + '#Headings', BPLink: HOME + '/nav/heading/' },
		{  name:'headers.msg.headerOnlyAlt',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.warn', WCAG_2_0Link: WCAGHOME + '#Headings', BPLink: HOME + '/nav/heading/' },
		{  name:'imagemaps.msg.missingRedundantTextLink',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/text/map/' },
		{  name:'imagemaps.msg.missingalt',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/text/map/' },
		{  name:'imagemaps.msg.emptyalt',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/text/map/' },
		{  name:'links.warnings.tooshort',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.warn', WCAG_2_0Link: WCAGHOME + '#Link_Rules', BPLink: HOME + '/nav/link/' }, 
		{  name:'links.warnings.outofcontext',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.suggestion', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#Link_Rules', BPLink: HOME + '/nav/link/' },
		{  name:'links.warnings.sameURLdiffLinks',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.warn', WCAG_2_0Link: WCAGHOME + '#Link_Rules', BPLink: HOME + '/nav/link/' }, 
		{  name:'links.warnings.sameLinkdiffURL',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.fail', WCAG_2_0Link: WCAGHOME + '#Link_Rules', BPLink: HOME + '/nav/link/' },
		{  name:'links.warnings.inCloseProxomity',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.suggestion', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#Link_Rules', BPLink: '' },
		{  name:'links.warnings.imgTooSmall',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.warn', WCAG_2_0Link: WCAGHOME + '#Link_Rules', BPLink: HOME + '/nav/link/' },
		{  name:'links.warnings.altequaltextcontent',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.warn', WCAG_2_0Link: WCAGHOME + '#Link_Rules', BPLink: HOME + '/nav/link/' },
		{  name:'navigation.warnings.menuwithoutheader',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced',  BPLink: HOME + '/nav/menu/' },
		{  name:'navigation.warnings.menuwithoutheaderARIA',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.warn',  BPLink: HOME + '/nav/menu/' },
		{  name:'navigation.msg.nonefound',IITAA :'msg.suggestion',icita07 :'msg.suggestion',icita08 :'msg.unenforced',  BPLink: HOME + '/nav/menu/' },
		{  name:'forms.msg.missinglegend',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.suggestion', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/form/' },
		{  name:'forms.msg.encapsulatinglabel',IITAA :'msg.suggestion',icita07 :'msg.suggestion',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/form/' },
		{  name:'forms.msg.missinglabelandtitle',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.fail', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/form/' },
		{  name:'forms.msg.missingaltandtitle',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.fail', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/form/' },
		{  name:'forms.msg.missingvalueandtitle',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.fail', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/form/' },
		{  name:'forms.msg.missingbuttoncontent',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.fail', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/form/' },
		{  name:'forms.msg.duplicatelabel',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.fail', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/form/' },	
		//		{  name:'forms.msg.badornostyle','msg.unenforced','msg.suggestion', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/form/' },	
		//		{  name:'forms.msg.nonfocusablesibling','msg.unenforced','msg.suggestion', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/form/' },	
		{  name:'forms.msg.emptylable',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.fail', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/form/' },	
		{  name:'forms.msg.emptylegend',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.fail', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/form/' },	
		{  name:'forms.msg.emptytitle',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.fail', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/form/' },	
		{  name:'forms.msg.duplicateID',IITAA :'msg.fail',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.warn', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/form/' },	
		{  name:'dataTables.msg.missingsummary',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.suggestion', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/dtable/' },
		{  name:'dataTables.msg.missingheaders',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.suggestion', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/dtable/' },
		{  name:'dataTables.msg.duplicatesummary',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.suggestion', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/dtable/' },
		{  name:'dataTables.msg.thmissingID',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.suggestion', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/dtable/' },
		{  name:'dataTables.msg.duplicateID',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.suggestion', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/dtable/' },
		{  name:'dataTables.msg.tdmissingheaders',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.suggestion', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/dtable/' },
		{  name:'dataTables.msg.invalidIDREF',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.suggestion', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/dtable/' },
		{  name:'languages.msg.invalidLanguage',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.fail', WCAG_2_0Link: WCAGHOME + '#Language_Rules', BPLink: HOME + '/nav/lang/' },
		{  name:'accesskey.msg.duplicate',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/accesskey/' },
		{  name:'accesskey.msg.ieconflict',IITAA :'msg.suggestion',icita07 :'msg.suggestion',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/accesskey/' },
		{  name:'w3c.msg.missingmetatag',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/standards/html/' },
		{  name:'w3c.msg.missingdoctype',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/standards/html/' },
		{  name:'textflow.msg.poor',IITAA :'msg.suggestion',icita07 :'msg.suggestion',icita08 :'msg.warn', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: '' },
		{  name:'textflow.msg.good',IITAA :'msg.suggestion',icita07 :'msg.suggestion',icita08 :'msg.note', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: '' },
		{  name:'lists.msg.fakelistusingchars',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/list/' },
		{  name:'lists.msg.fakelistusingimgs',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/list/' },
		{  name:'lists.msg.toodeep',IITAA :'msg.suggestion',icita07 :'msg.suggestion',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/list/' },	
		{  name:'textsizing.msg.absolute',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.suggestion', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: '' },
		{  name:'textstyling.msg.bold',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/style/text/' },
		{  name:'textstyling.msg.blinkmarquee',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.fail', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/style/text/' },
		{  name:'textstyling.msg.fontcenter',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/style/text/' },
		{  name:'textstyling.msg.italics',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/style/text/' },
		{  name:'textstyling.msg.underline',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/style/text/' },
		{  name:'layoutTables.msg.issubtable',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/style/layout/' },
		{  name:'layoutTables.msg.isdeeptable',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/style/layout/' },		
		{  name:'frames.warnings.missingtitle',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/frame/' },
		{  name:'frames.msg.duplicatetitle',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/frame/' },
		{  name:'frames.msg.emptyframe',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/nav/frame/' },
		{  name:'images.warnings.altmissing',IITAA :'msg.fail',icita07 :'msg.fail',icita08 :'msg.fail', WCAG_2_0: 'msg.fail', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/text/info/' },
		{  name:'images.warnings.altempty',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: 'http://bestpractices.cita.uiuc.edu/html/text/info/' },
		{  name:'images.warnings.altother',IITAA :'msg.note',icita07 :'msg.note',icita08 :'msg.note', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: 'http://bestpractices.cita.uiuc.edu/html/text/info/' },
		{  name:'images.msg.imgTooSmall',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: 'http://bestpractices.cita.uiuc.edu/html/text/info/' },
		{  name:'images.msg.imgForStyle',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.warn', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/text/desc/' },
		{  name:'images.msg.altbadlen',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.warn', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/text/info/' },
		{  name:'images.msg.althasfileext',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.warn', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/text/info/' },
		{  name:'images.msg.altforbidenword',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.warn', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/text/info/' },
		{  name:'object.warnings.altmissingapplet',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.fail', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: '' },
		{  name:'object.warnings.altmissingembed',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.fail', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: '' },
		{  name:'object.warnings.textmissing',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.fail', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: '' },
		{  name:'events.warnings.missingonfocus',IITAA :'msg.warn',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/script/onmouseover/' },
		{  name:'events.warnings.missingonblur',IITAA :'msg.warn',icita07 :'msg.fail',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/script/onmouseover/' },
		{  name:'events.msg.nonfocusableonmouse',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/script/onmouseover/' },
		{  name:'events.msg.nonfocusableonclick',IITAA :'msg.warn',icita07 :'msg.warn',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/script/onclick/' },
		{  name:'events.msg.selectonchange',IITAA :'msg.suggestion',icita07 :'msg.suggestion',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/script/onchange/' },
		{  name:'events.msg.missingkeyequiv',IITAA :'msg.suggestion',icita07 :'msg.suggestion',icita08 :'msg.unenforced', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/script/onmousedown/' },		
		{  name:'ariawidget.warnings.inValidGlobalStatesProps',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.warn', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: '' },
		{  name:'ariawidget.warnings.unsupportedstate',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.warn', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: '' },
		{  name:'ariawidget.warnings.invalidAttributeValue',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.warn', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: '' },
		{  name:'ariawidget.warnings.invalidIDREF',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.warn', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: '' },
		{  name:'ariawidget.warnings.emptyIDREF',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.warn', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: '' },
		{  name:'ariawidget.warnings.toomanyIDREF',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.warn', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: '' },
		{  name:'ariarelationships.warnings.emptydestination',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.fail', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: '' },
		{  name:'ariarelationships.warnings.undefinedrelation',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.warn', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: '' },
		{  name:'colorcontrast.warnings.belowminimal',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.fail', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/style/contrast/' },
		{  name:'colorcontrast.warnings.belowoptimal',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.warn', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: HOME + '/style/contrast/' },
		{  name:'colorcontrast.msg.usesFontAttr',IITAA :'msg.unenforced',icita07 :'msg.unenforced',icita08 :'msg.suggestion', WCAG_2_0: 'msg.unenforced', WCAG_2_0Link: WCAGHOME + '#', BPLink: '' },	
	];

	function treeboxObject(id,columns,defCol) {
		this.columns = columns;
		this.id = id;
		this.sortColumn = defCol;
		this.treeNode = document.getElementById(id);
		//activeTreeboxes[id] = this;
	};
	treeboxObject.prototype = {
		columns : Array(),
		sortColumn : false,
		id : false,
		sortDirAscending : true,
		treeNode : null,
		dataArray : Array(),
		updateSortColumn : function(col) {
			if (col == this.sortColumn) {
				this.sortDir = !this.sortDir;
			} else {
				this.sortDirAscending = true;
				this.sortColumn = col;
			}
		},
		setDataArray : function(dataArray) {
			this.dataArray = dataArray;
		},
		updateTreeView : function() {
			var i;
			//Clear the children and create a new one
			var treeChildren = accessext_clearTreeItems(this.treeNode);
			
			//Sort
			//First clear all directions
			var cols = this.treeNode.getElementsByTagName("treecols");
			if (cols.length == 1) {
				for (i = 0; i < cols[0].childNodes.length; i ++) {
					cols[0].childNodes[i].setAttribute("sortDirection","");
				}
			}
			
			var sc = document.getElementById(this.sortColumn);
		
			sc.setAttribute("sortDirection", this.sortDirAscending ? "ascending" : "descending");
			
			sortDirectionAscending = this.sortDirAscending;
			AE.sortProperty = this.columns[sortColumn];
			
			this.dataArray.sort(accessext_sortColumnElements);
			
			//Finally add elements to the list
			for (i = 0; i < this.dataArray.length; i ++) {
				var item = dataarray[i].getTreeNode(document);
				item.setAttribute("value", i);
				treeChildren.appendChild(item);
			}
		}
	}

AccessibilityExtension.LIB.extend(AccessibilityExtension.LIB,
{	
	
	getErrMsgSeverityCode: function(accessIssuesMessage, strStandard) {
		var severity = '';
		for (var i = 0; i < errMsgArray.length && severity == ''; i++) {
			if (errMsgArray[i].name == accessIssuesMessage) {
				if (strStandard == 'icita08') severity = errMsgArray[i].icita08;
				else severity = errMsgArray[i].icita07;
				if (strStandard == 'icita07') severity = errMsgArray[i].icita07;
				else if (strStandard == 'icita08') severity = errMsgArray[i].icita08;
				else if (strStandard == 'WCAG_2_0')severity = errMsgArray[i].WCAG_2_0;
				else severity = errMsgArray[i].IITAA;
			}
		}
		return severity;	
	}, 
	
	getErrMsgSeverity: function(accessIssuesMessage, strStandard) {
		var severity = '';
		for (var i = 0; i < errMsgArray.length && severity == ''; i++) {
			if (errMsgArray[i].name == accessIssuesMessage) {
				if (strStandard == 'icita07') severity = accessext_getBundleSingleString(errMsgArray[i].icita07);
				else if (strStandard == 'icita08') severity = accessext_getBundleSingleString(errMsgArray[i].icita08);
				else if (strStandard == 'WCAG_2_0')severity = accessext_getBundleSingleString(errMsgArray[i].WCAG_2_0);
				else severity = accessext_getBundleSingleString(errMsgArray[i].IITAA);
			}
		}
		return severity;	
	},
	
	setMaxSeverityForArray: function(loadArray) {
		for (i = 0; i < loadArray.length; i++) {
			var obj = loadArray[i];
			obj.icita07 = getMaxSeverity(obj, 'icita07');		
			obj.icita08 = getMaxSeverity(obj, 'icita08');		
		}
	},
	
	getMaxSeverity: function(obj, strStandard) {
		var retSeverity = '';
		var naCount = 0;
		for (var j = 0; j < obj.displayDetails.accessIssuesDataElementNames.length; j++) {
			var issue = obj.displayDetails.accessIssuesDataElementNames[j];
			var severity = getErrMsgSeverity(obj.displayDetails.accessIssuesMessages[j], strStandard);
			if (severity == 'NA') { naCount++; }
			if (obj[issue] == true) {
				if (retSeverity.toLowerCase() != 'fail') {
					var severity = getErrMsgSeverity(obj.displayDetails.accessIssuesMessages[j], strStandard);
					if (retSeverity.toLowerCase() != 'warn') {
						if (severity != 'NA') { retSeverity = severity; }
					//	retSeverity = severity;
					}
				}
			} 
		}
		if (retSeverity == '') {
			if (naCount != obj.displayDetails.accessIssuesDataElementNames.length) {
				retSeverity = accessext_getBundleSingleString('msg.pass');
			} else {
				retSeverity = 'NA';
			}
		}
		
		return retSeverity;
	},
	
	getMaxSeverityCode: function(obj, strStandard) {
		var retSeverity = '';
		var naCount = 0;
		for (var j = 0; j < obj.displayDetails.accessIssuesDataElementNames.length; j++) {
			var issue = obj.displayDetails.accessIssuesDataElementNames[j];
			var severity = getErrMsgSeverityCode(obj.displayDetails.accessIssuesMessages[j], strStandard);
			if (severity == 'msg.unenforced') { naCount++; }
			if (obj[issue] == true) {
				if (retSeverity.toLowerCase() != 'msg.fail') {
					var severity = getErrMsgSeverityCode(obj.displayDetails.accessIssuesMessages[j], strStandard);
					if (retSeverity.toLowerCase() != 'msg.warn') {
						if (severity != 'msg.unenforced') { retSeverity = severity; }
					//	retSeverity = severity;
					}
				}
			} 
		}
		if (retSeverity == '') {
			if (naCount != obj.displayDetails.accessIssuesDataElementNames.length) {
				retSeverity = 'msg.pass';
			} else {
				retSeverity = 'NA';
			}
		}
		
		return retSeverity;
	},	
	
	getErrMsgBPLink: function(accessIssuesMessage) {
		var BPLink = '';
		for (var i = 0; i < errMsgArray.length && BPLink == ''; i++) {
			if (errMsgArray[i].name == accessIssuesMessage) {BPLink = errMsgArray[i].BPLink;}
		}
		return BPLink;	
	},
	
	accessext_setNoteCaption: function() {
	 	var noteCaption = document.getElementById("groupbox-note-caption");
		if (null!= noteCaption) {
			noteCaption.setAttribute("label", getAccesessibilityInfoCaption());
		}	
	},
		
	initTreebox: function() {
		var cols = new Array();//loading unncessary, all cols use the format: cols['list-header-order'] = 'order';
		tbObj = new treeboxObject('treebox',cols,'list-header-order');
	},
	
	newTreeboxObject: function(id,columns,defCol) {
		var n = new treeboxObject(id,columns,defCol);
		return n; 
	},
	
	accessext_treeClassToggleSortColumn: function(id,col) {
		var a = activeTreeboxes[id];
		if (!a) {
			return;
		}
		a.updateSortColumn(col);
		a.updateTreeView();
	},
	
	// Generates the tree-displayable version of the object
	// A treeitem containing one treerow and treecells for every entry in the columnNames array,
	// ... with the corresponding label values set from the object.
	accesxt_generateTreeboxResults: function(doc, obj, columnNames) {
		try {
			var item, child;
			var row = doc.createElement("treerow");
			var columnNames = obj.displayDetails.dataElementNames;
			
			for (var col in columnNames) {
				var colName = columnNames[col];
				child = doc.createElement("treecell");
				var value = (obj[colName] == null) ? "" : obj[colName].toString();
				child.setAttribute("id",colName);
				child.setAttribute("label",value);
				row.appendChild(child);
			}
			item = doc.createElement("treeitem");
			item.appendChild(row);
			
			setRowColor(obj, item);	
		
			return item;
		} catch (ex) {
			accessext_consoleDump('accesxt_generateTreeboxResults exception: ', ex);
		}
	},
	
	scrollTreeboxToRow: function(tbx, row) {
		tbx.view.selection.clearSelection();
		tbx.view.selection.select(row);
		if (row <= tbx.treeBoxObject.getFirstVisibleRow() || row >= tbx.treeBoxObject.getLastVisibleRow()) {
			tbx.treeBoxObject.scrollToRow(row);
		}
	},
	
	setRowColor: function(obj, item) {
		try {
			if ( typeof( obj.displayDetails.accessIssuesUseObjectFunctions ) != "undefined" ) {
				if (obj.displayDetails.accessIssuesUseObjectFunctions == true) {
					obj.setRowColor(item);
				}
			}
			
			var row = item.getElementsByTagName('treerow');	
			var rowType = '';
			for (var j = 0; j < obj.displayDetails.accessIssuesDataElementNames.length; j++) {
				var issue = obj.displayDetails.accessIssuesDataElementNames[j];
				if (obj[issue] == true) {
					if (rowType != 'failRow') {
						var severity = getErrMsgSeverity(obj.displayDetails.accessIssuesMessages[j], currStandard());
						if (rowType != 'warnRow') {
							rowType = severity.toLowerCase() + 'Row';
						}
					}
				}
			}
			if (rowType != '') {
				row[0].setAttribute('properties',rowType);
			}
		} catch (ex) {
			accessext_consoleDump('setRowColor exception: ', ex);
		}
	},
	
	getNoteText: function(obj) {
		try {
			if (typeof( obj ) == "undefined") {return ''}
			var note = '';
			if ( typeof( obj.displayDetails.accessIssuesUseObjectFunctions ) != "undefined" ) {
				if (obj.displayDetails.accessIssuesUseObjectFunctions == true) {
					return obj.getNoteText();
				}
			}
			
			for (var j = 0; j < obj.displayDetails.accessIssuesDataElementNames.length; j++) {
				var issue = obj.displayDetails.accessIssuesDataElementNames[j];
				if (obj[issue] == true) {
					var severity = getErrMsgSeverity(obj.displayDetails.accessIssuesMessages[j], currStandard());
					if (severity != accessext_getBundleSingleString('msg.unenforced')) {
						var issueMsg = obj.displayDetails.accessIssuesMessages[j];
						note = note + severity + ': ' + accessext_getBundleSingleString(issueMsg) + ' \n';				
					}
				}
			}
			return note;
		} catch (ex) {
			accessext_consoleDump('getNoteText exception: ', ex);
		}
	},
	
	getIssueFrequency: function(srcarray) {
		try {
			if (srcarray.length > 0) {
				var obj = srcarray[0];
				obj.displayDetails.issueFrequency = new Array();
				for (var j = 0; j < obj.displayDetails.accessIssuesDataElementNames.length; j++) {
					obj.displayDetails.issueFrequency[j] = 0;
				}
				
				for (var i = 0; i < srcarray.length; i++) {
					obj = srcarray[i];
					for (var j = 0; j < obj.displayDetails.accessIssuesDataElementNames.length; j++) {
						var issue = obj.displayDetails.accessIssuesDataElementNames[j];
						if (obj.display == true && obj[issue] != false && obj[issue] != null) { //ie. true or non null
							obj.displayDetails.issueFrequency[j] = obj.displayDetails.issueFrequency[j] + 1;						
						}
					}
				}
			}
		} catch (ex) {
			accessext_consoleDump('IssueFrequency exception: ', ex);
		}
	},
	
	issueFrequencyInHTML: function(srcarray) {
		try {
			var html ='';
			if (srcarray.length > 0) {
				var obj = srcarray[0];
				for (var j = 0; j < obj.displayDetails.accessIssuesDataElementNames.length; j++) {
					var severity = getErrMsgSeverity(obj.displayDetails.accessIssuesMessages[j]);
					var issueMsg = obj.displayDetails.accessIssuesMessages[j];
					var objclass = obj.displayDetails.accessIssuesMessages[j].substring(0, issueMsg.indexOf('.')) + '.title';
					html = html + "<tr><td>" + obj.displayDetails.issueFrequency[j] + "</td><td>" + severity + "</td><td>" + accessext_getBundleSingleString(issueMsg) + "</td><td>" + accessext_getBundleSingleString(objclass) +  "</td></tr>";
				}
			}
			return html;
			
		} catch (ex) {
			accessext_consoleDump('getIssueFrequency exception: ', ex);
		}
	},
	
	accessext_tree_autoselect_main: function() {
		if (AE.primaryarray.length > 0 && AE.treebox_main.currentIndex < 0) {
			AE.treebox_main.currentIndex=0;
			AE.treebox_main.view.selection.select(0);
			accessext_handle_treebox_main();
		}
	},
	
	accessext_tree_autoselect: function() {
		if (AE.dataarray.length > 0 && AE.treebox.currentIndex < 0) {
			AE.treebox.currentIndex=0;
			AE.treebox.view.selection.select(0);
			accessext_handle_treebox();
		}
	},
	
	accessext_setWidth: function(id,width) {
		try {
			if (id == "") return;
			var element = document.getElementById(id);
			if (element && element.id == id && (element.localName.toLowerCase() == 'treecol' || element.localName.toLowerCase() == 'vbox')) {
				element.width = width;
			}
			return;
		} catch (ex) {
			accessext_consoleDump('accessext_setWidth exception: ', ex);
		}
	},
	
	accessext_setHeight: function(id,height) {
		try {
			if (id == "") return;
			var element = document.getElementById(id);
			if (element && element.id == id && (element.localName.toLowerCase() == 'treecol' || element.localName.toLowerCase() == 'vbox')) {
				element.height = height;
			}
			return;
		} catch (ex) {
			accessext_consoleDump('accessext_setHeight exception: ', ex);
		}
	},
	
	accessext_setVisibleColumn: function(id) {
		if (id == "") return;
		var element = document.getElementById(id);
		if (element && element.id == id && element.localName.toLowerCase() == 'treecol') {
			element.hidden = false;
		}
	},
	
	accessext_loadDialogPrefs: function() {
		try {
			var pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("");
	
			var dialogID = AE.dialogName; //duplicates when in sidebar
			if (dialogID == 'sidebar') {dialogID = sidebarNameToTitle();}
			
			var x, y = '';
			var prefStr = dialogID + '.dialogPosX';
			if (pref.prefHasUserValue(prefStr)) {x = pref.getCharPref(prefStr);	}
			prefStr = dialogID + '.dialogPosY';
			if (pref.prefHasUserValue(prefStr)) {y = pref.getCharPref(prefStr);	}
			if (x != '' && y != '') self.moveTo(parseInt(x), parseInt(y));
	
			prefStr = dialogID + '.dialogWidth';
			if (pref.prefHasUserValue(prefStr)) {
				var value = pref.getCharPref(prefStr);
				if (value != '') {window.innerWidth = value;}
	   		}
			prefStr = dialogID + '.dialogHeight';
			if (pref.prefHasUserValue(prefStr)) {
				var value = pref.getCharPref(prefStr);
				if (value != '') {window.innerHeight = value;}
			}
			prefStr = dialogID + '.showColumns';
			if (pref.prefHasUserValue(prefStr)) {
				var valueForID = pref.getCharPref(prefStr);
				
				//This will only work with english version. The side bar saves its current settings after
				//savePreferences() saves the new columns setting in effect putting the old setting back.
				if (dialogID == 'accessext-form-List-of-Widgets' || dialogID == 'accessext-form-List-of-Widget-Relationships') {
					valueForID = valueForID.replace(/(icita07)|(icita08)/g, currStandard());
				}		
				
				var valueForWidth = '';
				prefStr = dialogID + '.ColumnWidths';
				if (pref.prefHasUserValue(prefStr)) {
					valueForWidth = pref.getCharPref(prefStr);
				}	
				if (valueForID != '') { 
					//hide all cols then unhide the cols wanted
					var cols = document.getElementsByTagName("xul:treecol"); //ff3
					if (cols.length == 0) {cols = document.getElementsByTagName("treecol");} //ff2
					for (var i = 0; i < cols.length; i ++) {
						cols[i].setAttribute("hidden", "true");
					}
					var colsForID = valueForID.split(',');
					var colsForWidth = valueForWidth.split(',');
					for (var i = 0; i < colsForID.length; i++) {
						accessext_setVisibleColumn(colsForID[i]);
						if (colsForWidth[i] != '') { accessext_setWidth(colsForID[i], colsForWidth[i]); }
					}			
				}
			}
			return true;
		} catch (ex) {
			accessext_consoleDump('accessext_loadDialogPrefs exception: ', ex);
		}
	},
	
	sidebarNameToTitle: function(){
		try {
			var dialogTitle = 'accessext-form-' + document.title; 
			dialogTitle = dialogTitle.replace(/\s+/g, '-');
			return dialogTitle; // so accessext_cmd_about_reset can reset them as well
		} catch (ex) {
			accessext_consoleDump('sidebarNameToTitle exception: ', ex);
		}
	},
	
	accessext_saveDialogPrefs: function() {
		try {
			var prefNameVal = "";
			var prefWidthVal = "";
	
			var cols = document.getElementsByTagName("xul:treecol"); //ff3
			if (cols.length == 0) {cols = document.getElementsByTagName("treecol");} //ff2
			for (var i = 0; i < cols.length; i ++) {
				if (!cols[i].hidden) {
					prefNameVal = prefNameVal + cols[i].getAttribute("id") + ",";
					prefWidthVal = prefWidthVal + cols[i].getAttribute("width") + ",";
				}
			}
	
			if (prefNameVal.length > 0) { prefNameVal = prefNameVal.substring(0,prefNameVal.length-1); }
			if (prefWidthVal.length > 0) { prefWidthVal = prefWidthVal.substring(0,prefWidthVal.length-1); }
			
			var dialogID = AE.dialogName; //duplicates when in sidebar
			if (dialogID == 'sidebar') {dialogID = sidebarNameToTitle();}
			var pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("");
			pref.setCharPref(dialogID + '.showColumns',prefNameVal);
			pref.setCharPref(dialogID + '.ColumnWidths',prefWidthVal);
			
			var winX = (document.all)?window.screenLeft:window.screenX;
			var winY = (document.all)?window.screenTop:window.screenY;
			pref.setCharPref(dialogID + '.dialogPosX',winX);
			pref.setCharPref(dialogID + '.dialogPosY',winY);
			try { //for List of Aria Widgets the following returns: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMXULDocument.width]
				pref.setCharPref(dialogID + '.dialogWidth',document.width); 
				pref.setCharPref(dialogID + '.dialogHeight',document.height); 
			} catch(ex) {}
			return true;
		} catch (ex) {
			accessext_consoleDump('accessext_saveDialogPrefs exception: ', ex);
		}
	},
	
	issueSummaryStandardSwitch: function() {
			alert('IN issueSummaryStandardSwitch: ');
		var standard = currStandard();
		for (var j = 0; j < dataarray.length; j++) {
			if (this.display == false && dataarray[j][standard] != '') {
				this.display = true;
			} else if (dataarray[j][standard] == '' && this.display == true) {
				this.display = false;
			}
		}
	},
	
	receiveMessage: function(event)
	{
		if (event.data == "differentStandard") {
		try {
			accessext_clearHighlightedNodes();	
			accessext_loadDialogPrefs();
			accessext_setNoteCaption();
			UpdateTreeView();
			accessext_setNoteText(0);	
	       } catch(e){
				accessext_consoleDump('receiveMessage exception: ', e);
		   }
		}
	}
});
}});